#include <iostream>
#include <string>
#include <string.h>

using namespace std;

int ans[100][100];
string str1 = "abcd";
string str2 = "abab";

void lcs()
{
    for (int i = 1; i <= str1.size(); ++i)
    {
        for (int j = 1; j <= str2.length(); ++j)
        {
            if (str1[j] == str2[j])
            {
                ans[i][j] = ans[i-1][j-1] + 1;
            }
            else
            {
                ans[i][j] = max(ans[i-1][j], ans[i][j-1]);
            }
        }
    }
    cout << ans[str1.size()][str2.size()] << endl;
}

int main()
{
    memset(&ans, 0, sizeof(ans));
    lcs();
    return 0;
}
